**************************************************************************************************
* Appendix for Changing Horses in Midstream: Leadership Changes and the Civil War Peace Process  *
**************************************************************************************************

sort dyadid year	
stset duration3, id(dyadep3) failure(outcome_st3==3)

**REGULAR and IRREGULAR government changes
logit negotiations L.regularchange mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity lnduration3 secession activedyads lnpop  negyears* if coup == 0, r cluster(dyadid)
estimates store m1
logit negotiations L.irregularchange mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity lnduration3 secession activedyads lnpop  negyears* if coup == 0, r cluster(dyadid)
estimates store m2

stcrreg regularchange mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity secession activedyads lnpop if coup == 0 & totaldeaths3 > 199, r cluster(dyadid) compete(outcome_st3 = 1,2,4,5) texp(ln(_t)) tvc(lnpop)
estimates store m3
stcrreg irregularchange mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity secession activedyads lnpop if coup == 0 & totaldeaths3 > 199, r cluster(dyadid) compete(outcome_st3 = 1,2,4,5) texp(ln(_t)) tvc(lnpop)
estimates store m4

estout m1 m2, cells(b (star fmt(%9.3f)) p(par)) stats(N N_sub N_fail chi2 ll , star fmt(%9.3f %9.0g)) 
estout m3 m4, cells(b (star fmt(%9.3f)) p(par)) stats(N N_sub N_fail chi2 ll , star fmt(%9.3f %9.0g)) eform

*CULPABLE LEADERS
logit negotiations culpable mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity lnduration3 secession activedyads lnpop  negyears*  if coup == 0, r cluster(dyadid)
estimates store m1
logit negotiations insiderculp mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity lnduration3 secession activedyads lnpop  negyears*  if coup == 0, r cluster(dyadid)
estimates store m2

stcrreg culpable lnt_culpable3  mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity secession activedyads lnpop if coup == 0 & totaldeaths3 > 199, r cluster(dyadid) compete(outcome_st3 = 1,2,4,5) texp(ln(_t)) tvc(lnpop)
estimates store m3
*nonph_graph combined_coefficient 90
stcrreg insiderculp mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity secession activedyads lnpop if coup == 0 & totaldeaths3 > 199, r cluster(dyadid) compete(outcome_st3 = 1,2,4,5) texp(ln(_t)) tvc(lnpop)
estimates store m4

estout m1 m2, cells(b (star fmt(%9.3f)) p(par)) stats(N N_sub N_fail chi2 ll , star fmt(%9.3f %9.0g)) 
estout m3 m4, cells(b (star fmt(%9.3f)) p(par)) stats(N N_sub N_fail chi2 ll , star fmt(%9.3f %9.0g)) eform

*DECAY FUNCTIONS (for insider and outsider change)
logit negotiations L.insiderdecay mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity lnduration3 secession activedyads lnpop  negyears* if coup == 0, r cluster(dyadid)
estimates store m1
logit negotiations L.outsiderdecay mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity lnduration3 secession activedyads lnpop  negyears* if coup == 0, r cluster(dyadid)
estimates store m2
stcrreg insiderdecay mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity secession activedyads lnpop if coup == 0 & totaldeaths3 > 199, r cluster(dyadid) compete(outcome_st3 = 1,2,4,5) texp(ln(_t)) tvc(lnpop)
estimates store m3
stcrreg outsiderdecay mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity secession activedyads lnpop if coup == 0 & totaldeaths3 > 199, r cluster(dyadid) compete(outcome_st3 = 1,2,4,5) texp(ln(_t)) tvc(lnpop)
estimates store m4

estout m1 m2, cells(b (star fmt(%9.3f)) p(par)) stats(N N_sub N_fail chi2 ll , star fmt(%9.3f %9.0g)) 
estout m3 m4, cells(b (star fmt(%9.3f)) p(par)) stats(N N_sub N_fail chi2 ll , star fmt(%9.3f %9.0g)) eform

*EXTERNAL INTERVENTION
logit negotiations L.insideronly govintervention rebintervention rebstrength2 terrcont polity2 milpers_ipop lnseverity lnduration3 secession activedyads lnpop  negyears* if coup == 0, r cluster(dyadid)
estimates store m1
logit negotiations L.outsiderv2 govintervention rebintervention rebstrength2 terrcont polity2 milpers_ipop lnseverity lnduration3 secession activedyads lnpop  negyears* if coup == 0, r cluster(dyadid)
estimates store m2
stcrreg insideronly govintervention rebintervention rebstrength2 terrcont polity2 milpers_ipop lnseverity secession activedyads lnpop if coup == 0 & totaldeaths3 > 199, r cluster(dyadid) compete(outcome_st3 = 1,2,4,5) texp(ln(_t)) tvc(lnpop)
estimates store m3
stcrreg outsiderv2 govintervention rebintervention rebstrength2 terrcont polity2 milpers_ipop lnseverity secession activedyads lnpop if coup == 0 & totaldeaths3 > 199, r cluster(dyadid) compete(outcome_st3 = 1,2,4,5) texp(ln(_t)) tvc(lnpop)
estimates store m4

estout m1 m2, cells(b (star fmt(%9.3f)) p(par)) stats(N N_sub N_fail chi2 ll , star fmt(%9.3f %9.0g)) 
estout m3 m4, cells(b (star fmt(%9.3f)) p(par)) stats(N N_sub N_fail chi2 ll , star fmt(%9.3f %9.0g)) eform

*REBEL LEADER CHANGES
sort dyadid year

*negotiations
logit negotiations L.rebelchange L.mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity lnduration3 secession activedyads lnpop negyears*  if coup == 0, r cluster(dyadid)
estimates store m1
logit negotiations L.rebelint L.mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity lnduration3 secession activedyads lnpop  negyears*  if coup == 0, r cluster(dyadid)
estimates store m2
logit negotiations L.rebelext L.mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity lnduration3 secession activedyads lnpop  negyears*  if coup == 0, r cluster(dyadid)
estimates store m3

estout m1 m2 m3, cells(b (star fmt(%9.3f)) p(par)) stats(N N_sub N_fail chi2 ll , star fmt(%9.3f %9.0g)) 

*settlements
stset duration3, id(dyadep3) failure(outcome_st3==3)

*insider/outsider change
stcrreg rebelchange mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity secession activedyads lnpop if coup == 0 & totaldeaths3 > 199, r cluster(dyadid) compete(outcome_st3 = 1,2,4,5) texp(ln(_t)) tvc(lnpop)
estimates store m4
stcrreg rebelint mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity secession activedyads lnpop if coup == 0 & totaldeaths3 > 199, r cluster(dyadid) compete(outcome_st3 = 1,2,4,5) texp(ln(_t)) tvc(lnpop)
estimates store m5
stcrreg rebelext mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity secession activedyads lnpop if coup == 0 & totaldeaths3 > 199, r cluster(dyadid) compete(outcome_st3 = 1,2,4,5) texp(ln(_t)) tvc(lnpop)
estimates store m6

estout m1 m2 m3, cells(b (star fmt(%9.3f)) p(par)) stats(N  ll chi2, star fmt(%9.3f %9.0g)) 
estout m4 m5 m6, cells(b (star fmt(%9.3f)) p(par)) stats(N  ll chi2, star fmt(%9.3f %9.0g))  eform

*ONE-YEAR BREAK (Settlement Models)
stset duration, id(dyadep)failure(outcome_st==3) 

*insider/outsider change
stcrreg insideronly mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity secession activedyads lnpop if coup == 0 & totaldeaths3 > 199, r cluster(dyadid) compete(outcome_st = 1,2,4,5) texp(ln(_t)) tvc(lnpop)
estimates store m1
stcrreg outsiderv2 mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity secession activedyads lnpop if coup == 0 & totaldeaths3 > 199, r cluster(dyadid) compete(outcome_st = 1,2,4,5) texp(ln(_t)) tvc(lnpop)
estimates store m2
stcrreg nonsolsch mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity secession activedyads lnpop if coup == 0 & totaldeaths3 > 199, r cluster(dyadid) compete(outcome_st = 1,2,4,5) texp(ln(_t)) tvc(lnpop)
estimates store m3
stcrreg solschdum mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity secession activedyads lnpop if coup == 0 & totaldeaths3 > 199, r cluster(dyadid) compete(outcome_st = 1,2,4,5) texp(ln(_t)) tvc(lnpop)
estimates store m4

estout m1 m2 m3 m4, cells(b (star fmt(%9.3f)) p(par)) stats(N N_sub N_fail chi2 ll , star fmt(%9.3f %9.0g)) eform


**DIFFERENT DEATH THRESHOLDS**
stset duration3, id(dyadep3) failure(outcome_st3==3)

*insider change
stcrreg insideronly mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity secession activedyads lnpop if coup == 0 & totaldeaths3 > 24, r cluster(dyadid) compete(outcome_st3 = 1,2,4,5) texp(ln(_t)) tvc(lnpop)
estimates store m1
stcrreg insideronly mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity secession activedyads lnpop if coup == 0 & totaldeaths3 > 99, r cluster(dyadid) compete(outcome_st3 = 1,2,4,5) texp(ln(_t)) tvc(lnpop)
estimates store m2
stcrreg insideronly mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity secession activedyads lnpop if coup == 0 & totaldeaths3 > 199, r cluster(dyadid) compete(outcome_st3 = 1,2,4,5) texp(ln(_t)) tvc(lnpop)
estimates store m3
stcrreg insideronly mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity secession activedyads lnpop if coup == 0 & totaldeaths3 > 399, r cluster(dyadid) compete(outcome_st3 = 1,2,4,5) texp(ln(_t)) tvc(lnpop)
estimates store m4
stcrreg insideronly mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity secession activedyads lnpop if coup == 0 & totaldeaths3 > 699, r cluster(dyadid) compete(outcome_st3 = 1,2,4,5) texp(ln(_t)) tvc(lnpop)
estimates store m5

estout m1 m2 m3 m4 m5, cells(b (star fmt(%9.3f)) p(par)) stats(N N_sub N_fail chi2 ll , star fmt(%9.3f %9.0g)) eform

*TIME FUNCTIONS FOR NEGOTIATIONS MODELS
logit negotiations L.insideronly L.mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity lnduration3 secession activedyads lnpop negyears if coup == 0, r cluster(dyadid)
estimates store m1
logit negotiations L.insideronly L.mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity lnduration3 secession activedyads lnpop negever if coup == 0, r cluster(dyadid)
estimates store m2
logit negotiations L.insideronly L.mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity lnduration3 secession activedyads lnpop spline* if coup == 0, r cluster(dyadid)
estimates store m3

logit negotiations L.outsiderv2 L.mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity lnduration3 secession activedyads lnpop negyears if coup == 0, r cluster(dyadid)
estimates store m4
logit negotiations L.outsiderv2 L.mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity lnduration3 secession activedyads lnpop negever if coup == 0, r cluster(dyadid)
estimates store m5
logit negotiations L.outsiderv2 L.mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity lnduration3 secession activedyads lnpop spline* if coup == 0, r cluster(dyadid)
estimates store m6

estout m1 m2 m3 m4 m5 m6, cells(b (star fmt(%9.3f)) p(par)) stats(N  ll chi2, star fmt(%9.3f %9.0g)) 

**ADDITIONAL OUTCOMES**

**Government Victory**
stset duration3, id(dyadep3) failure(outcome_st3==1)

*insider/outsider change
stcrreg insideronly mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity secession activedyads lnpop if coup == 0 & totaldeaths3 > 199, r cluster(dyadid) compete(outcome_st3 = 2,3,4,5) texp(ln(_t)) tvc(lnpop)
estimates store m1
stcrreg outsiderv2 mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity secession activedyads lnpop if coup == 0 & totaldeaths3 > 199, r cluster(dyadid) compete(outcome_st3 = 2,3,4,5) texp(ln(_t)) tvc(lnpop)
estimates store m2

*SLOS Leader Changes Data 
	**SLOS == outsider
stcrreg nonsolsch mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity secession activedyads lnpop if coup == 0 & totaldeaths3 > 199, r cluster(dyadid) compete(outcome_st3 = 2,3,4,5) texp(ln(_t)) tvc(lnpop)
estimates store m3
stcrreg solschdum mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity secession activedyads lnpop if coup == 0 & totaldeaths3 > 199, r cluster(dyadid) compete(outcome_st3 = 2,3,4,5) texp(ln(_t)) tvc(lnpop)
estimates store m4

estout m1 m2 m3 m4, cells(b (star fmt(%9.3f)) p(par)) stats(N N_sub N_fail chi2 ll , star fmt(%9.3f %9.0g)) eform

**Low Activity**
stset duration3, id(dyadep3) failure(outcome_st3==2)

*insider/outsider change 
stcrreg insideronly mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity secession activedyads lnpop if coup == 0 & totaldeaths3 > 199, r cluster(dyadid) compete(outcome_st3 = 1,3,4,5) texp(ln(_t)) tvc(lnpop)
estimates store m1
stcrreg outsiderv2 mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity secession activedyads lnpop if coup == 0 & totaldeaths3 > 199, r cluster(dyadid) compete(outcome_st3 = 1,3,4,5) texp(ln(_t)) tvc(lnpop)
estimates store m2

*SLOS Leader Changes Data 
	**SLOS == outsider
stcrreg nonsolsch  mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity secession activedyads lnpop if coup == 0 & totaldeaths3 > 199, r cluster(dyadid) compete(outcome_st3 = 1,3,4,5) texp(ln(_t)) tvc(lnpop)
estimates store m3
stcrreg solschdum  mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity secession activedyads lnpop if coup == 0 & totaldeaths3 > 199, r cluster(dyadid) compete(outcome_st3 = 1,3,4,5) texp(ln(_t)) tvc(lnpop)
estimates store m4

estout m1 m2 m3 m4, cells(b (star fmt(%9.3f)) p(par)) stats(N N_sub N_fail chi2 ll , star fmt(%9.3f %9.0g)) eform

**Rebel Victory**
stset duration3, id(dyadep3) failure(outcome_st3==4)

*insider/outsider change
stcrreg insideronly mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity secession activedyads lnpop if coup == 0 & totaldeaths3 > 199, r cluster(dyadid) compete(outcome_st3 = 1,2,3,5) texp(ln(_t)) tvc(lnpop)
estimates store m1
stcrreg outsiderv2 mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity secession activedyads lnpop if coup == 0 & totaldeaths3 > 199, r cluster(dyadid) compete(outcome_st3 = 1,2,3,5) texp(ln(_t)) tvc(lnpop)
estimates store m2

*SLOS Leader Changes Data 
	**SLOS == outsider
stcrreg nonsolsch mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity secession activedyads lnpop if coup == 0 & totaldeaths3 > 199, r cluster(dyadid) compete(outcome_st3 = 1,2,3,5) texp(ln(_t)) tvc(lnpop)
estimates store m3
stcrreg solschdum mediation rebstrength2 terrcont polity2 milpers_ipop lnseverity secession activedyads lnpop if coup == 0 & totaldeaths3 > 199, r cluster(dyadid) compete(outcome_st3 = 1,2,3,5) texp(ln(_t)) tvc(lnpop)
estimates store m4

estout m1 m2 m3 m4, cells(b (star fmt(%9.3f)) p(par)) stats(N N_sub N_fail chi2 ll , star fmt(%9.3f %9.0g)) eform

**ENDOGENEITY TESTS**
set more off
sort dyadid year 

logit insideronly L.lngovdeaths L.lnrebdeaths  polity2 milpers_ipop rebstrength2 terrcont lnseverity lnduration3 secession activedyads lnpop spline* if coup == 0 & totaldeaths3 > 199 & dyadep3 != ., r cluster(dyadid) 
estimates store m1
logit outsider2 L.lngovdeaths L.lnrebdeaths  polity2 milpers_ipop rebstrength2 terrcont lnseverity lnduration3 secession activedyads lnpop spline* if coup == 0 & totaldeaths3 > 199 & dyadep3 != ., r cluster(dyadid) 
estimates store m2
logit regularch L.lngovdeaths L.lnrebdeaths  polity2 milpers_ipop rebstrength2 terrcont lnseverity lnduration3 secession activedyads lnpop spline* if coup == 0 & totaldeaths3 > 199 & dyadep3 != ., r cluster(dyadid) 
estimates store m3
logit irregularch L.lngovdeaths L.lnrebdeaths  polity2 milpers_ipop rebstrength2 terrcont lnseverity lnduration3 secession activedyads lnpop spline* if coup == 0 & totaldeaths3 > 199 & dyadep3 != ., r cluster(dyadid)
estimates store m4

estout m1 m2 m3 m4, cells(b (star fmt(%9.3f)) p(par)) stats(N chi2 ll , star fmt(%9.3f %9.0g))
coefplot m1 m2 m3 m4, drop(lnrebdeaths  polity2 milpers_ipop rebstrength2 terrcont lnseverity lnduration3 secession activedyads lnpop spline* _cons) xline(0) graphregion(color(white))
